using System.Collections;
using System.Collections.Generic;
using GameLogic.AbilitySystem;
using UnityEngine;
using GameLogic.AbilitySystem.Attribute;
using Unity.VisualScripting;
using UnityEngine.AI;


namespace GameLogic.Character
{
    [RequireComponent(typeof(AbilitySystemComponent))]
    public class CharacterBase : MonoBehaviour
    {
        /// <summary>
        /// 导航代理
        /// </summary>
        private NavMeshAgent _navMeshAgent;

        public AbilitySystemComponent asc
        {
            get
            {
                return GetComponent<AbilitySystemComponent>();
            }
        }

        public void Awake()
        {
            gameObject.layer = LayerMask.NameToLayer("Character");
            _navMeshAgent = this.GetOrAddComponent<NavMeshAgent>();
        }

        /// <summary>
        /// 移动到目标位置
        /// </summary>
        public void MoveTo(Vector3 Target)
        {
            _navMeshAgent.speed = asc.AttributeSet.attributeSet.GetAttribute(AttributeType.MoveSpeed).CurrentValue;
            _navMeshAgent.angularSpeed = asc.AttributeSet.attributeSet.GetAttribute(AttributeType.TurnSpeed).CurrentValue;
            _navMeshAgent.acceleration = 1000f;
            _navMeshAgent.destination = Target;
        }
    }

}